<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>履历添加</title>
    <link rel="stylesheet" href="../static/css/weui.css"/>
    <link rel="stylesheet" href="../static/css/example.css"/>
    <link rel="stylesheet" href="../static/css/jquery-weui.css"/>
    <link rel="stylesheet" href="../static/css/publish.css"/>
    <script src="../static/js/zepto.min.js"></script>
    <script src="../static/js/example.js"></script>
    <script src="../static/js/weui.min.js"></script>
    <script type="text/javascript" src="../static/js/jquery-weui.js"></script>
</head>
<body ontouchstart>
 <div class="page" style="opacity: 1;">
  <div class="weui-cells weui-cells_form" id="get-info" style="margin-top: 30px">
  <div class="weui-cell" style="padding-top: 5px;padding-bottom: 5px;padding-left: 10px;padding-right: 10px;">
        <div class="weui-cell select" style="padding-left: 4px;padding-right: 4px;">
        <div class="type_title weui-cell__hd"><label for="name" class="weui-label " style="color: #9b9b9b;margin-right: 50px">履历类型</label></div>
        <div class="type_select weui-cell__bd">
          <input class="weui-input" id="type" type="text" value="" readonly="" style="width: 100px;"><span class="triangle" style="color: #9b9b9b">▼</span>
        </div>
      </div>
  </div>
  </div>

    <div class="weui-cell" style="padding-left:0px;padding-right: 0px;padding-bottom: 0px">
         <div class="weui-cell note" style="background-color: #FFFFFF;width: 100%">
           <div class="weui-cell__bd">
               <textarea class="weui-input" id="note" placeholder="请输入" style="height: 100px;"></textarea>
           </div>
         </div>
    </div>

     <div class="weui-btn-area" style="padding-top: 0px;background-color: burlywood;margin-left: 15px;margin-right: 15px;">
      <a type="button" id="submit" class="weui-btn confirm" >提交</a>
     </div>
 </div>
</body>
</html>
<script src="../static/js/fastclick.js"></script>
<script type="text/javascript" src="../static/js/mui.min.js"></script>
<script type="text/javascript" src="../static/js/jquery-weui.js"></script>
<script type="text/javascript">
    $("#type").select({
  items: [
    {
      title: "学生干部经历",
      value: "1",
    },
    {
      title: "获奖情况",
      value: "2",
    },
    {
      title: "科研经历",
      value: "3",
    },
    {
      title: "社会实践",
      value: "4",
    },
    {
      title: "特长",
      value: "5",
    },
    {
      title: "其他",
      value: "6",
    }
  ]
});
</script>

<script type="text/javascript">
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
        var context = "";
        if (r != null)
            context = r[2];
            reg = null;
            r = null;
        return context == null || context == "" || context == "undefined" ? "" : context;
}
        uid = GetQueryString("uid");
    $('#submit').on("click", function () {
        var postdata = {};
        var text = $('#note').val().trim();
        var type =  $('#type').val();
            if (type == "学生干部经历"){
               type = '1'
            }
            else if (type == "获奖情况") {
                type = '2'
            }
            else if (type == "科研经历"){
                type = '3'
            }
            else if (type == "社会实践"){
                type = '4'
            }
            else if (type == "特长"){
                type = '5'
            }
            else if(type == "其他")
            {
                type = '6'
            }
            else {type = '7'}
        var post_url= '{{ url_for('remark.publish_handle') }}';
        var date = new Date();
        var time = date.toLocaleDateString();
        postdata['text'] = text;
        postdata['type'] = type;
        postdata['time'] = time;
        postdata['uid'] = uid;
        if (type === '7') {
                       $.toast("未选择备注类型", "forbidden");
                          return false;}
        if (text.length === 0) {
                      $.toast("提交内容不能为空", "forbidden");
                          return false;
                                }

        $.ajax({
                url: post_url,
                type: "POST",
                data: JSON.stringify(postdata),
                processData: false,  // 不处理数据
                contentType: false,   // 不设置内容类型
                success: function (result) {
                                 $.toast('成功',400, function () {
                                      window.location.href = "/remark/publish?uid="+uid;
                                });
                        },
                error: function() {
                                  alert('提交失败，请刷新页面后重试', function () {
                                  $('.weui-mask').fadeOut(200);
                             });
                        }
            });
        })

</script>
